{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf390
{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
{\colortbl;\red255\green255\blue255;\red0\green0\blue191;\red96\green96\blue96;\red191\green0\blue0;
}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\f0\fs24 \cf0 (\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\cf2 	SynthDef\cf0 (\cf3 "JSTestRetrigger"\cf0 , \
	\{ \cf2 arg\cf0  t_trig = 0, envCurve = -7, attackDuration = 0.05, bufnum = 1, outBus = 0,  thresh = 0.004, duration = 2, amp = 1, bufferPosition = 200, pan = 0;\
	\
	\cf2 var\cf0  trigger, gatedAmp, triggerBool, outamp, bufferFrames, bufRateScale;\
	\cf2 var\cf0  bufPointer, env, envGenList, outList, triggerList, maxOverlaps;\
	\
	bufferFrames = \cf2 BufFrames\cf0 .kr(bufnum);\
	bufRateScale = \cf2 BufRateScale\cf0 .kr(bufnum);\
	triggerBool = (t_trig >= thresh); \
	gatedAmp = \cf2 Latch\cf0 .kr(t_trig, triggerBool); \cf4 //hang on to the trigger value longer\cf0 \
	outamp = (gatedAmp * amp);  \cf4 //scale the trigger by the amp scaler\cf0 \
	\
	maxOverlaps = 10;\
	trigger = \cf2 Trig1\cf0 .kr(triggerBool, duration / maxOverlaps);\
	\cf4 //Sendtrigger.kr (trigger, triggerID, outamp); //send a trigger to the client\cf0 \
	\
	triggerList = \cf2 List\cf0 .series(maxOverlaps);\
	envGenList = \cf2 List\cf0 .series(maxOverlaps);\
	outList = \cf2 List\cf0 .series(maxOverlaps);\
	\
	bufPointer = \cf2 PulseCount\cf0 .kr(trigger);\
	\cf4 //Buffer position pointer.  \cf0 \
	\cf4 //This gets moved after each trigger in the dynamic version\cf0 \
	\
	env = \cf2 Env\cf0 .perc(attackDuration, (duration - attackDuration), outamp, envCurve);\
	\cf4 //an envelope (Env.something)\cf0 \
	\
	maxOverlaps.do(\{ \cf2 arg\cf0  i;\
		triggerList.put(i, \cf2 PulseDivider\cf0 .kr(trigger, maxOverlaps, i));\
		envGenList.put(i, \cf2 EnvGen\cf0 .kr(env, triggerList.at(i)));\
		outList.put(i, \cf2 PlayBuf\cf0 .ar(1, bufnum, bufRateScale, triggerList.at(i),\
		            (bufPointer*bufferPosition)%bufferFrames)*envGenList.at(i));\
	   \});\
	\cf2 Out\cf0 .ar(outBus, \cf2 Pan2\cf0 .ar(sum(outList), pan));\
	\
	\}).play(s);\
)\
s.sendMsg('/b_allocRead', 1, '/Volumes/Docs/Users/jonathan/Desktop/superConductorFugueAsPerformedMundial/trunk/sandBox/kryptonite/PerformanceSounds/fugueMonoRegular/wobbleyThingLong.wav.short.wav');\
s.sendMsg('/n_set', 1001, 't_trig', 1);}